package com.itheima.filter.service.impl;

import com.itheima.filter.service.inter.ReportService;
import com.itheima.mapper.ReportMapper;
import com.itheima.project.UseCount;
import com.itheima.project.Job;
import com.itheima.project.classdata.ClazzData;
import com.itheima.project.jobData;
import com.itheima.project.student.ClazzCountOption;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ReportServiceIml implements ReportService {

    @Resource
   private ReportMapper reportMapper;
    public jobData countEmp() {

        List<Job> jobs = reportMapper.countEmp();
        List<String> jobList = jobs.stream().map(Job::getJob).toList();
        List<Integer> dataList = jobs.stream().map(Job::getNum).toList();

        return new jobData(jobList,dataList);
    }

    @Override
    public List countGender() {

      List<UseCount> list = reportMapper.countGender();

        return list;
    }

    @Override
    public List studentDegreeCount() {

      List<UseCount> list = reportMapper.studentDegreeCount();
        return list;
    }

    @Override
    public ClazzCountOption studentCountData() {
        List<ClazzData> list = reportMapper.studentCountData();
        List<String> clazzList = list.stream().map(clazzData -> clazzData.getClazzName()).toList();
        List<Integer> dataList = list.stream().map(clazzData -> clazzData.getNum()).toList();

        return new ClazzCountOption(clazzList,dataList);
    }
}
